﻿<%@ Page Title="售后处理进度" Language="C#" MasterPageFile="~/Wap/Shop/ShopSite.Master" AutoEventWireup="true"
    CodeBehind="ReturnsProgress.aspx.cs" Inherits="ZLCMS.Web.Wap.Shop.ReturnsProgress" %>
<%@ Register src="Footer.ascx" tagname="Footer" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
#remarkPage .tuikuanbtn{ margin:2em 1em;}
#remarkPage .tuikuanbtn a{ background:#f9384d; color:#fff; border-radius: 0; font-size:14px; padding:0.5em 0; display:block; text-align:center; border:none;}

</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="pages" runat="server">
    <div data-role="page" id="mypage">
        <div data-role="header">
        </div>

        <!-- /header -->
        <div role="main" class="ui-content">
            <!--s integral-->
            <div class="refundTop">
                <a href="ReturnsList.aspx" data-ajax="false"><img src="images/arrowLeftCom.png" /></a>
                售后处理进度
            </div>

            <div class="refundbox">
                <div class="apply_refund">
                    <div class="title">问题描述：</div>
                    <div class="txt" id="remark"></div>
                </div>
                <div class="apply_refund" id="processRemarkTips" style="display:none">
                    <div class="title">处理留言：</div>
                    <div class="txt" id="processRemark"></div>
                </div>
            </div>

            <div class="integral">
                <div class="title">
                    <div class="left">处理进度：<span prop="Data.OrderNo"></span></div>
                    <div class="right" prop="Data.OrderTime"></div>
                </div>
                <div class="box" style="padding-top: 1em;">
                </div>
                <div loader="returns">
                </div>
                <div class="tuikuanbtn" >
                <div style="display: none;" id="finishTips" >
                    <a href="javascript:void(0)" onclick="$.mobile.changePage('#remarkPage')" style="float: left; width: 49%;" data-role="button" data-mini="true"
                        data-theme="i">追加描述</a>
                    <a href="javascript:void(0)" onclick="finishReturnProgress()" data-role="button" style="float: right; width: 49%;"
                        data-mini="true" data-shadow="false" data-theme="i" id="btnFinish">完成本次申请</a> 
                </div>
                <div style="display: none;" id="optTips" >
                    <a href="javascript:void(0)" onclick="$.mobile.changePage('#remarkPage')" style="float: left; width: 49%;" data-role="button" data-mini="true"
                        data-theme="i">追加描述</a>
                    <a href="javascript:void(0)" onclick="canCelReturnProgress()" style="float: right; width: 49%;" data-role="button" data-mini="true"
                        data-theme="i" id="btnCancel">取消本次申请</a>
                </div>
                </div>
            </div>
            <!--e integral-->
        </div>
        <!-- /content -->

	    <div data-role="footer" data-position="fixed" data-tap-toggle="false">    
                    <uc1:Footer ID="Footer1" runat="server" MenuId="M" />    
        </div>
        <!-- /footer -->

    </div>


        <!--popup-->
<div data-role="page" id="remarkPage">
    <div role="main" class="ui-content">
        <div class="ui-title ui-bar"  style="margin-top:10px; font-size: 12px; color: #666;">请填写您对本次售后申请的更多描述：</div>    
        <div class="refundbox">            
        <form id="remarkForm" style="margin:0 1em;" command='Member.ApplyReturnComment'>
            <input type="hidden" command-param='MemberAccount' />
            <input id="ImageList" command-param='ImageList' type="hidden" />
            <input type="hidden" command-param='ReturnId' value="<%= string.IsNullOrEmpty(Request["rid"])?"0": Request["rid"]%>" />
            <textarea cols="40" rows="8" name="ReturnMemo" id="ReturnMemo" placeholder="请在此添加描述详细" data-rule="required;wordcount" command-param='ReturnMemo' data-rule-wordcount="[/^.{1,700}$/, '请输入1-700个字']"></textarea>
            <div><span class="msg-box" for="ReturnMemo"></span></div> 
            
            <div class="addphoto" style="margin: 1em 0px;">
                <ul class="addphoto_list">
                    
                </ul>
                <div class="addphoto_upload">
                    <a href="javascript:void(0)" onclick="uploadImage();"> 
                        <img src="/wap/shop/images/addphoto.png"><p>上传图片</p>
                    </a>
                </div>
                <div style="font-size: 12px; color:#666; margin-top: 10px;">请上传能反映问题的图片，以便商城售后人员能尽快确认并处理问题</div>
                <div style="font-size: 12px; color:#999;">由于微信限制，图片暂时只能支持一张张上传</div>
            </div>             
        </form>

        <div class="tuikuanbtn" style=" background:none; margin:0 1em; text-align: center;">
            <a href="javascript:void(0)" style="float: left; width: 49%;" onclick="SubmitForm(this);" data-role="button" data-mini="true" data-theme="o">确定</a>
            <a href="javascript:void(0)" style="float: right; width: 49%;" onclick="$.mobile.changePage('#mypage')" data-role="button" data-mini="true" data-theme="o">返回</a>
        </div>
        </div>
    </div>
</div>
        <!-- /popup -->


    <link rel="stylesheet" href="/wap/lib/validator-0.7.0/css/jquery.validator.css" />
    <script type="text/javascript" src="/wap/lib/validator-0.7.0/jquery.validator.js"></script>
    <script type="text/javascript" src="/wap/lib/validator-0.7.0/local/zh_CN.js"></script>

    <script src="/wap/lib/common/listviewHandler.js" type="text/javascript"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            queryData();
        });

        function queryData() {
            var param = $.extend({}, { MemberAccount: '<%=CurrentMemberAccount %>',ReturnId:<%=string.IsNullOrEmpty(Request["rid"])?"0":Request["rid"] %> });
            var handler = $('div[loader=returns]').listviewHandler();
            handler.initialize({
                loaderBtn: $('#btnMore'), //加载数据按钮（点击加载下一页）
                emptyHtml: '', //无记录时显示此html
                itemTemplate: ' <div class="box">'
                + ' <h2>'
                + ' <img src="/wap/shop/images/quan.png" class="icon">'
                + '   <div class="time"><h3>{RecordDate}</h3><p>{RecordTime}</p></div>'
                + ' </h2>'
                + ' <div class="textbox">'
                + '      <div class="text">'
                + '         <h3>{Title}</h3>'
                + '         <div class="txt">{Memos}</div>'
                + '         <div class="imglist">{imglist}</div>'
                + '        <div class="position"><img src="/wap/shop/images/arrow_left.png"></div>'
                + '     </div>'
                + ' </div>'
                + ' </div>', //项模板
                pageIndex: 1, //页码（从1起算）
                pageSize: 20, //页大小
                totalCount: 999, //总记录数
                beforeHandleResult: function (result, totalCount, container) {
                    $('#remark').text(result.ReturnsInfo.ReturnMemos);

                    if(result.ReturnsInfo.ProcessRemark != null)
                    {
                        $('#processRemarkTips').show();
                        $('#processRemark').text(result.ReturnsInfo.ProcessRemark);
                    }

                    //显示完成售后按钮
                    if(result.IsReturnFinish){
//                    $('#btnFinish').show(); 
                    $('#finishTips').show();}
                    else{ 
//                    $('#btnFinish').hide(); 
                    $('#finishTips').hide();}

                    //显示取消售后按钮
                    if(result.IsReturnCancelable){
                    $('#optTips').show(); 
//                    $('#btnCancel').show(); 
                    }
                    else{ 
                    $('#optTips').hide();
//                    $('#btnCancel').hide();
                    }
                }, 
                itemHandler: function (data, itemTemplate, container) {//数据各项处理
                    var str = data.RecodeDate.replace(/-/g, "/");
                    var date = new Date(str);                    
                    var dateMon = date.getMonth() + 1;
                    var dateDay = date.getDate();
                    data.RecordDate = (dateMon < 10 ? "0" + dateMon : dateMon) + "-" + (dateDay < 10 ? "0" + dateDay : dateDay);
                    data.RecordTime = date.getHours()+":"+date.getMinutes();
                                        
                    data.imglist = '';
                    try {
                        var fileArr = $.parseJSON(data.ThumbnailImg);
                        var imageUrlTemp = '<img src="{ImageUrl}" />';
                        $(fileArr).each(function () {
                            this.ImageUrl = ($.cookie('imagesvr') ? $.cookie('imagesvr') : '') + this.FilePath;
                            data.imglist += imageUrlTemp.format(this);
                        });
                    } catch (e) { };

                    return itemTemplate.format(data);
                },
                command: 'Member.LoadReturnProgressList',
                parameter: param
            });
            handler.nextPage();
        }

        //完成订单
function finishReturnProgress() {
    confirmDialog('是否确认完成本次售后申请？', function () {
    $('#btnFinish').removeAttr("onclick");
        $('#btnFinish').executeCommand({ 
        successCallBack: function () {showTips('操作成功',500, function(){location.reload();}); },
        errorCallback: function (errorCode, msg) {showTips(msg);}
        },'Member.FinishReturnProgress', { MemberAccount: '<%=CurrentMemberAccount %>',ReturnId:<%=string.IsNullOrEmpty(Request["rid"])?"0":Request["rid"] %> });
    });
}

function canCelReturnProgress() {
    confirmDialog('是否确认取消本次售后申请？', function () {
    $('#btnCancel').removeAttr("onclick");
        $('#btnCancel').executeCommand({ 
        successCallBack: function () {showTips('操作成功',500, function(){location.reload();});},
        errorCallback: function (errorCode, msg) {showTips(msg);}
        },'Member.CancelReturnProgress', { MemberAccount: '<%=CurrentMemberAccount %>',ReturnId:<%=string.IsNullOrEmpty(Request["rid"])?"0":Request["rid"] %> });
          });
}

    

    $('input[prop]').bind('valuechange', function (event, param) {
        $(this).val(param.value);
    });

    function SubmitForm(ct) {
        var svrids = '';
        $('.addphoto_list>li[sid]').each(function () { svrids += $(this).attr('sid') + ','; });
        $('#ImageList').val(svrids);
        return executeFormCommonCommand('remarkForm', SubmitApply, SubmitErr);

    }
    function SubmitApply() {
        showTips("提交成功！", 500, function () {

            location.replace(GetUrlRelativePath());
        });
    }

    function SubmitErr(errorCode, msg) {
        showTips(msg, 1000, function () { });
    }
        
    function uploadImage() {
        wx.chooseImage({
            success: function (res) {
                var localIds = res.localIds;
                if (localIds) {
                }
                wx.uploadImage({
                    localId: localIds[0],
                    isShowProgressTips: 1,
                    success: function (res) {
                        getLocalImg(localIds[0], function (src) {
                            var html = '<li sid="' + res.serverId + '">'
                            + ' <img src="' + src + '" /> <a href="javascript:void();"onclick="removeImg(this)" class="delete-pto"></a>'
                            + '</li>';

                            $('.addphoto_list').append(html);
                            alert('上传成功');
                        });
                    }
                });
            }
        });
    }
      function getLocalImg(localId, callback) {
            var localData = "";
            if (window.__wxjs_is_wkwebview) {
                wx.getLocalImgData({
                    localId: localId, // 图片的localID
                    success: function (resData) {
                        callback && callback(resData.localData);

                    }
                });
            } else {
                callback && callback(localId);
            }
        }
    function removeImg(container) {
        confirmDialog('确认删除？', function () { $(container).parent().parent().remove(); }, function () { })
    }

    </script>
</asp:Content>
